package cn.com.darly.vpm.business.amuse.impl;

import cn.com.darly.vpm.business.amuse.bean.Amuse;
import cn.com.darly.vpm.business.amuse.bean.AmuseExample;
import cn.com.darly.vpm.business.amuse.dao.AmuseMapper;
import cn.com.darly.vpm.business.amuse.service.AmuseService;
import cn.com.darly.vpm.framework.base.AbstractBaseService;
import cn.com.darly.vpm.framework.base.BaseMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Darly/张宇辉/2018/5/3 11:53
 * @version 1.0/cn.com.darly.vpm.index.amuse.impl
 */
@Service
public class AmuseServiceImplementer extends AbstractBaseService<Amuse,AmuseExample> implements AmuseService {

    @Autowired
    AmuseMapper amuseMapper;

    @Override
    protected BaseMapper<Amuse, AmuseExample> getBaseMapper() {
        return amuseMapper;
    }

    @Override
    public List<Amuse> findAll() {
        AmuseExample search = new AmuseExample();
        return this.amuseMapper.selectByExample(search);
    }

    @Override
    public PageInfo<Amuse> getAmuse(Integer pageNo, Integer pageSize) {
        pageNo = pageNo == null ? 1 : pageNo;
        pageSize = pageSize == null ? 10 : pageSize;
        PageHelper.startPage(pageNo, pageSize);
        AmuseExample search = new AmuseExample();
        search.createCriteria().andStatusEqualTo(1);
        List<Amuse> list = amuseMapper.selectByExample(search);
        PageInfo<Amuse> page = new PageInfo<Amuse>(list);
        //用PageInfo对结果进行包装
        return page;
    }

}
